package com.imageim.yimirror.ui.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.imageim.yimirror.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Yuaihen.
 * on 2018/11/29
 * 滑动切换Fragment Adapter
 */
public class SlideSwitchFragmentAdapter extends FragmentPagerAdapter {

    private List<BaseFragment> mFragmentList = new ArrayList<>();

    public SlideSwitchFragmentAdapter(FragmentManager fm, List<BaseFragment> list) {
        super(fm);
        if (list != null) {
            mFragmentList.addAll(list);
        }
    }

    public void updateData(List<BaseFragment> list) {
        if (list != null) {
            mFragmentList.clear();
            mFragmentList.addAll(list);
        }
    }


    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    //    @Override
    //    public int getItemPosition(@NonNull Object object) {
    //        return PagerAdapter.POSITION_NONE;
    //    }
}
